package com.lejin.cms.controller;


import com.lejin.cms.service.ICourseCatService;
import com.lejin.item.entity.CourseOutline;
import com.lejin.vo.CatCascadeVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author luminghua
 * @since 2022-04-21
 */
@RestController
@RequestMapping("/cms/course-cat")
public class CourseCatController {



    @Autowired
    private ICourseCatService courseCatService;

    //首页二级分类菜单列表，已声明api
    @RequestMapping("findCat")
    public List<CatCascadeVO> findCat(){
        return courseCatService.selectCatCascade();
    }

    //首页某个一级分类下价格最低的4个课程
    @RequestMapping("findCourseByPriceAsc/{catId}")
    public List<CourseOutline> findCourseByPriceAsc(@PathVariable String catId){
        return courseCatService.selectCoursesByCatIdAndPriceAsc(catId);
    }

    //首页某个二级分类下点击量最高的8个课程
    @RequestMapping("findCourseByHitsDesc/{cat2Id}")
    public List<CourseOutline> findCourseByHitsDesc(@PathVariable String cat2Id){
        return courseCatService.selectCoursesByHitsDesc(cat2Id);
    }
}
